#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

#include <math.h>

int* printNumbers(int n, int* returnSize)
{
    // write code here

    *returnSize = pow(10, n) - 1;
    int* arr = (int*)malloc(sizeof(int) * 100000);
    for (int i = 0; i < *returnSize; i++)
    {
        arr[i] = i + 1;
    }

    //(*returnSize)--;
    return arr;
}


#include <stdio.h>

int main()
{

    int year = 0;
    int month = 0;
    int day = 0;

    scanf("%d %d %d", &year, &month, &day);
    int arr[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };

    int sum = 0;
    for (int i = 0; i < month; i++)
    {
        sum += arr[i];
    }
    sum += day;

    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0 && month > 2)
    {
        sum++;
    }

    printf("%d", sum);
    return 0;
}